package com.qfedu.yanglao20app.companionapp.controller;

import com.qfedu.yanglao20.common.CommonResult;
import com.qfedu.yanglao20.common.annotation.LogInfo;
import com.qfedu.yanglao20.entity.companion.Companion;
import com.qfedu.yanglao20app.companionapp.service.CompanionService;
import com.qfedu.yanglao20app.companionapp.vo.LoginCompanion;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "应用服务管理")
@RestController
@RequestMapping("/app/companion")
public class CompanionController {

    @Resource
    private CompanionService companionService;

    /**
     * 陪护员登录
     *
     * @param loginCompanion 陪护员登录信息
     * @return jwt格式字符串
     */
    @LogInfo
    @ApiOperation(value = "陪护员登录", notes = "登录陪护员客户端")
    @PostMapping("/login")
    public CommonResult<String> login(LoginCompanion loginCompanion) {
        return CommonResult.success(companionService.login(loginCompanion));
    }

    /**
     * 查询转单陪护员下拉列表
     *
     * @param id 当前陪护员id
     * @return 陪护员列表
     */
    @LogInfo
    @ApiOperation(value = "下拉列表", notes = "查询转单陪护员下拉列表")
    @GetMapping("/transfer")
    public CommonResult<List<Companion>> transfer(@ApiParam("陪护员id") Integer id, @ApiParam("转单订单号") String indentId) {
        return CommonResult.success(companionService.selectAll(id));
    }

}
